<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8">
	<title>文章列表--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<!--查询条件-->
<div class="layui-collapse" id="search">
	<blockquote class="layui-elem-quote quoteBox">
		<form class="layui-form" >
		    <div class="layui-form-item layui-row">
		        <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购单编号</label>
                	<div class="layui-input-block">
                		<input type="text" name="purchaseNum" class="layui-input searchVal" placeholder="请输入采购单编号" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购单名称</label>
                	<div class="layui-input-block">
                		<input type="text" name="purchaseName" class="layui-input searchVal" placeholder="请输入采购单名称" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md3">
                    <label class="layui-form-label">采购单状态</label>
                	<div class="layui-input-inline">
                	    <select name="purchaseState" id="purchaseState" lay-filter="purchaseState" >
                            <option>请选择采购状态：</option>
                		</select>
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">采购时间</label>
                	<div class="layui-input-inline">
                		<input type="text" class="layui-input" name="startTime" id="startTime" placeholder="yyyy-MM-dd">
                	</div>
                	<label class="layui-form-label" style="width: 5px">-</label>
                	<div class="layui-input-inline">
                    	<input type="text" class="layui-input" name="endTime" id="endTime" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-block layui-col-md3">
                    <label class="layui-form-label">医院名称</label>
                	<div class="layui-input-block">
                	    <input name="hospitalId" type="hidden">
                		<input type="text" id="moHospitalName" name="hospitalName" class="layui-input searchVal" placeholder="请输入医院名称" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-center">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit="" lay-filter="sub">查询</button>
                </div>
              </div>
		</form>
	</blockquote>
</div>
<!--数据表格-->
<div>
    <table class="layui-hide" id="purchaseTable" lay-filter="purchaseTable"></table>
    <div id="toolBars" style="display: none">
    </div>
    <div id="rowBars" style="display: none">
        <button type="button" lay-event="show" class="layui-btn layui-btn-sm layui-btn-warm"><span class="layui-icon layui-icon-search"></span>查看</button>
        <button type="button" lay-event="pass" class="layui-btn layui-btn-sm layui-btn-warm"><span class="layui-icon layui-icon-search"></span>通过</button>
        <button type="button" lay-event="nopass" class="layui-btn layui-btn-sm layui-btn-warm"><span class="layui-icon layui-icon-search"></span>不通过</button>
    </div>
</div>

<!--查看-->
<div id="addOrUpdate" style="display: none">
    <form class="layui-form" id="addOrUpdateTable" lay-filter="addOrUpdateTable">
	    <div class="layui-form-item">
	        <div class="layui-inline ">
                <label class="layui-form-label">医院编号</label>
            	<div class="layui-input-inline">
            	    <input type="hidden" name="id">
            		<input type="text" name="hospitalId" id="hospitalId" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">医院名称</label>
            	<div class="layui-input-inline">
            		<input type="text" name="hospitalName" id="hospitalName" class="layui-input searchVal" readonly />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">采购单编号</label>
            	<div class="layui-input-inline">
            	    <input name="purchaseNum" class="layui-input searchVal" id="purchaseNum" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">采购单名称</label>
            	<div class="layui-input-inline" style="width: 300px;">
            	    <input name="purchaseName" readonly class="layui-input searchVal" lay-verify="required" id="purchaseName" placeholder="请输入采购单名称" >
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">采购时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="createTime" class="layui-input createTime" lay-verify="required" readonly placeholder="yyyy-MM-dd">
            	</div>
            </div>
            <div class="layui-inline ">
            	<label class="layui-form-label">结束时间</label>
            	<div class="layui-input-inline">
                	<input type="text" class="layui-input" name="overTime" lay-verify="required" readonly id="overTime" placeholder="yyyy-MM-dd">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">联系人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="linkman" class="layui-input searchVal" placeholder="请输入联系人" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">联系电话</label>
            	<div class="layui-input-inline">
            		<input type="text" name="linkphone" lay-verify="required|phone" class="layui-input searchVal" placeholder="请输入联系电话" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">采购单状态</label>
            	<div class="layui-input-inline">
            		<select name="purchaseState" id="purchaseSta" lay-filter="purchaseSta">
                        <option>请选择采购状态：</option>
                    </select>
            	    <div class="mydiv" title="不可修改" style="position:absolute;width: 100%;height: 100%;left: 0px;top: 0px;background: #fff;opacity: 0;filter:alpha(opacity=0)"></div>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">提交时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="submitTime" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-block ">
                <label class="layui-form-label">备注</label>
            	<div class="layui-input-block" style="width: 515px">
            		<input type="text" name="remark" class="layui-input searchVal" placeholder="请输入备注" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">审核人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="auditor" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">审核时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="auditorTime" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">建单时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="createTime" readonly class="layui-input searchVal createTime" placeholder="yyyy-MM-dd"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">审核意见</label>
            	<div class="layui-input-inline">
            		<input type="text" name="auditorAdvice" readonly class="layui-input searchVal" placeholder="请输入审核意见" />
            	</div>
            </div>
            <div class="layui-form-item layui-center">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit="" id="doSubmit" lay-filter="doSubmit">提交</button>
                </div>
            </div>
        </div>
	</form>
</div>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script>
    layui.use(['form','laydate','element','layer','jquery','table'],function(){
        var form = layui.form;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var $ = layui.jquery;
        var table = layui.table;
        var date = new Date();
        //下拉框渲染
        select($("#purchaseState"),"/getPurchaseState",1);

        $.get("/getPurchaseState",function(data) {
            var html = "<option value='0'>请选择采购状态：</option>";
            $.each(data.data,function(index,item) {
                if(item.dataNum!=3){//去除审核通过的
                    if(item.dataNum===2){
                        html += "<option selected value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }else {
                        html += "<option value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }
                }
            })
            $("#purchaseState").empty();
            $("#purchaseState").append(html);
            // $("#purchaseState").html(html);
            form.render();
        })
        //填充医院名称
        var hospitalId;
        $.ajax({
            url:"/getSessionUnitId",
            async:false,
            dataType:"json",
            type:"get",
            success:function(res) {
                hospitalId = res;
                $("input[name='hospitalId']").val(res);
            }
        });
        if(hospitalId!=null&&hospitalId!=undefined){
            $.get("/hospital/getHospitalById?id="+hospitalId,function(res) {
                $("#moHospitalName").val(res.hospitalName);
            })
        }
        laydate.render({
          elem: '#startTime'
          ,type: 'datetime'
        });
        laydate.render({
          elem: '#endTime'
          ,type: 'datetime'
        });
        var tableIns = table.render({
            elem:"#purchaseTable",
            url:"/purchase/loadAllPurchase2",
            toolbar:"#toolBars",
            page:true,
            id:"purchaseTable",
            where:{purchaseState:2},
            height:'full-290',
            cols:[
                [
                    {type:'checkbox',fixed:'center'}
                    ,{field:'id', title:'ID',  fixed: 'left', unresize: true,width:'80' ,sort: true,align:'center'}
                    ,{field:'auditorAdvice', edit:true, title:'审核意见',align:'center',width:'150'}
                    ,{field:'hospitalName', title:'医院名称',align:'center',width:'180'}
                    ,{field:'purchaseNum', title:'采购单编号',align:'center',width:'150'}
                    ,{field:'purchaseName', title:'采购单名称',align:'center',width:'150'}
                    ,{field:'createTime', title:'开始时间',align:'center',width:'180',templet:function(res) {
                        return res.createTime.substring(0,11);
                    }}
                    ,{field:'overTime', title:'结束时间',align:'center',width:'180',templet:function(res) {
                        return res.overTime.substring(0,11);
                    }}//TODO
                    ,{field:'createTime', title:'建单事件',align:'center',width:'180',templet:function(res) {
                        return res.createTime.substring(0,11);
                    }}
                    ,{field:'submitTime', title:'提交时间',align:'center',width:'180'}
                    ,{field:'auditorTime', title:'审核时间',align:'center',width:'180'}
                    ,{field:'purchaseState', title:'审核单状态',align:'center',width:'180',templet:function(d) {
                        return d.purchaseState==1?"未提交":d.purchaseState==2?"审核中":d.purchaseState==3?"审核通过":"审核不通过";
                    }}
                    ,{fixed: 'right', title:'操作', toolbar: '#rowBars',width:260}
                ]
            ]
        })
        //表单提交
        form.on("submit(sub)",function(data) {
            tableIns.reload({
                where:data.field
            })
            return false;
        })
        var mainIns;
        var url;
        //监听头部工具栏事件
        table.on('toolbar(purchaseTable)',function(obj) {
            switch (obj.event) {

            }
        });
        //监听行工具栏事件
        table.on('tool(purchaseTable)',function(obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'show':
                    openShow(data);
                    break;
                case 'pass':
                    openUpdate(data);
                    break;
                case 'nopass':
                    openDelete(data);
            }
        });
        //提交表单
        form.on('submit(doSubmit)',function() {
            var params = $("#addOrUpdateTable").serialize();
            $.post(url,params,function(data) {
                //提示信息
                layer.msg(data.msg);
                //关闭弹出层
                layer.close(mainIns);
                //重新渲染table
                tableIns.reload();
                //跳转到采购维护
                if(url=="/purchase/add"&&data.code==200){
                    $.post("/purchase/getNewPurchaseId",function(id) {
                        window.location.href = "/toPurchaseMaintain?id="+id;
                    })
                }
            })
            return false;
        })
        //打开查看弹出层
        var hDiv = $("#addOrUpdate").html();
        function openShow(data) {
            mainIns = layer.open({
                type:1,
                content:$("#addOrUpdate"),
                area:['800px','580px'],
                title:"查看采购单",
                success:function(index) {
                    $("#addOrUpdate").html(hDiv);
                    $("#showDataDrugForm").hide();
                    form.val("addOrUpdateTable",data);
                    select($("#purchaseSta"),"/getPurchaseState",data.purchaseState);
                    $("input[name='linkman']").attr("readonly",true);
                    $("input[name='linkphone']").attr("readonly",true);
                    $("input[name='remark']").attr("readonly",true);
                    $("#doSubmit").hide();
                    $.post("/getDrugMessageByPurchaseId",{purchaseId:data.id},function(res) {
                        console.log(res);
                        $.each(res,function(index,item) {
                            var categoryName = "";
                            $.ajax({
                                url:"/getDrugCategoryById?drugCategoryId="+item.drugCategory,
                                async:false,
                                dataType:"json",
                                type:"get",
                                success:function(res) {
                                    categoryName = res.category;
                                }
                            });
                            var html = '<form class="layui-form" >\n'+
                                        '\t    <h2>药品信息</h2>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '    \t        <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">药品名</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="hidden">\n'+
                                        '                \t\t<input type="text" value="'+(item.commodityName==null?"":item.commodityName)+'" class="layui-input searchVal" readonly />\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">药品流水号</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text"  value="'+(item.serialNumber==null?"":item.serialNumber)+'" class="layui-input searchVal" readonly />\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">药品通用名</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input value="'+(item.commonName==null?"":item.commonName)+'" class="layui-input searchVal" readonly />\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">批准文号</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.approvalNumber==null?"":item.approvalNumber)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">剂型</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.dosageForm==null?"":item.dosageForm)+'" class="layui-input" readonly>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                \t<label class="layui-form-label">规格</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                    \t<input type="text" class="layui-input" value="'+(item.size==null?"":item.size)+'" name="size" readonly>\n'+
                                        '                    </div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">单位</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" readonly value="'+(item.unit==null?"":item.unit)+'" class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">转换系数</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" readonly value="'+(item.factor==null?"":item.factor)+'" class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">质量层次</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.quality==1?"国家一类新药":
                                                                                                                    item.quality==2?"国家科学进步奖":
                                                                                                                    item.quality==3?"专利":
                                                                                                                    item.quality==4?"原研":
                                                                                                                    item.quality==5?"单独定价":
                                                                                                                    item.quality==6?"优质优价":
                                                                                                                    item.quality==7?"GMP":"")+'" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd" />\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">生产企业</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.productionName==null?"":item.productionName)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">药品类别</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(categoryName)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">通用名拼音</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.commodityPinyin==null?"":item.commodityPinyin)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">批准文号有效期</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.approvalDate==null?"":item.approvalDate)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">是否是进口药</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.isImport==null?"":item.isImport)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">包装材质</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.packages==null?"":item.packages)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">包装单位</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.packageUnit==null?"":item.packageUnit)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">最新零售价</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.newPrice==null?"":item.newPrice)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">零售价出处</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.priceSource==null?"":item.priceSource)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">质量层次说明</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.qualityDescription==null?"":item.qualityDescription)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">有无质检报告</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.haveReport==null?"":item.haveReport)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">质检报告编号</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.reportNum==null?"":item.reportNum)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">质检报告有效期</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.reportDate==null?"":item.reportDate)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '            <div class="layui-form-item">\n'+
                                        '                <div class="layui-inline">\n'+
                                        '                    <label class="layui-form-label">产品说明</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t    <input type="text" value="'+(item.productionDescription==null?"":item.productionDescription)+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '                <div class="layui-inline ">\n'+
                                        '                    <label class="layui-form-label">药品状态</label>\n'+
                                        '                \t<div class="layui-input-inline">\n'+
                                        '                \t\t<input type="text" value="'+(item.transaction==null?"":item.transaction==1?"正常":"不正常")+'" readonly class="layui-input searchVal"/>\n'+
                                        '                \t</div>\n'+
                                        '                </div>\n'+
                                        '            </div>\n'+
                                        '        </form>';
                            $("#addOrUpdate").append(html);
                        })
                    })
                }
            })
        }
        //打开通过弹出层
        function openUpdate(data) {
            var auditorTime = dateToString(new Date());
            $.post("/purchase/update",{id:data.id,auditorAdvice:data.auditorAdvice,purchaseState:3,auditorTime:auditorTime},function(res) {
                layer.msg(res.msg);
                tableIns.reload();
            });
        }
        //打开通过弹出层
        function openDelete(data) {
            var auditorTime = dateToString(new Date());
            $.post("/purchase/update",{id:data.id,auditorAdvice:data.auditorAdvice,purchaseState:4,auditorTime:auditorTime},function(res) {
                layer.msg(res.msg);
                tableIns.reload();
            });
        }
        //日期转字符串方法
        function dateToString(date) {
            return date.getFullYear()+"-"+
                    ("0"+(date.getMonth()+1)).slice(-2)+"-"+
                    ("0"+date.getDate()).slice(-2)+" "+
                    ("0"+date.getHours()).slice(-2)+":"+
                    ("0"+date.getMinutes()).slice(-2)+":"+
                    ("0"+date.getSeconds()).slice(-2)
        }
        //下拉框渲染
        function select(item,url,dataNum) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择采购状态：</option>";
                $.each(data.data,function(index,item) {
                    if(item.dataNum===dataNum){
                        html += "<option selected value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }else {
                        html += "<option value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
    })
</script>
</body>
</html>